package com.alks.function.controller.produce;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.entity.PcCuttingDispatchOther;
import com.alks.entity.data.page.PageParam;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.produce.*;
import com.alks.function.service.produce.ISuppDispatchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author MS
 * @since 2024/7/3上午11:50
 */
@RestController
@ApiRestController("/suppDispatch")
@Api(value = "生产部", tags = "生产部-生产作业-补单派工")
@Slf4j
public class SuppDispatchController {
    @Autowired
    private ISuppDispatchService service;

    private final String processCode = "02";

    @WebLogger
    @PostMapping("/suppDispatchHeadQuery")
    @ApiOperation(value = "首页查询-分页可条件查询", tags = "生产部-生产作业-补单派工")
    public ResponseInfo suppDispatchHeadQuery(@RequestBody DisOthHeadRequest request) {
        return service.suppDispatchHeadQuery(request,processCode);
    }

    @WebLogger
    @PostMapping("/suppDispatchDetailQuery")
    @ApiOperation(value = "首页明细查询-分页可条件查询", tags = "生产部-生产作业-补单派工")
    public ResponseInfo suppDispatchDetailQuery(@RequestBody DispatchOtherFindRequest request) {
        return service.suppDispatchDetailQuery(request,processCode);
    }

    @WebLogger
    @PostMapping("/suppDispatchTempQuery")
    @ApiOperation(value = "派工表单查询-条件查询", tags = "生产部-生产作业-补单派工")
    public ResponseInfo suppDispatchTempQuery(@Valid @RequestBody DisOthTempRequest request) {
        return ResponseInfo.ok(service.suppDispatchTempQuery(request,processCode));
    }

    @WebLogger
    @PostMapping("/suppDispatchPrintQuery")
    @ApiOperation(value = "派工表单打印查询-条件查询", tags = "生产部-生产作业-补单派工")
    public ResponseInfo suppDispatchPrintQuery(@RequestBody SuppDispatchPrintRequest request) {
        return service.suppDispatchPrintQuery(request,processCode);
    }

    @WebLogger
    @PostMapping("/suppDispatchEmpQuery")
    @ApiOperation(value = "手工人员查询-可条件查询", tags = "生产部-生产作业-补单派工")
    public ResponseInfo suppDispatchEmpQuery(@RequestParam(required = false)@ApiParam("搜索条件（员工ID和名字都能搜）") String searchKey) {
        return service.suppDispatchEmpQuery(searchKey,processCode);
    }

    @WebLogger
    @PostMapping("/suppDispatchSlipNoBack")
    @ApiOperation(value = "派工订单回显-回显", tags = "生产部-生产作业-补单派工")
    public ResponseInfo suppDispatchSlipNoBack(@RequestBody PageParam request, @RequestParam(required = false)@ApiParam("订单号（模糊匹配）") String slipNo) {
        return service.suppDispatchSlipNoBack(slipNo,request,processCode);
    }

    @WebLogger
    @PostMapping("/suppDispatchTempProcessBack")
    @ApiOperation(value = "工艺回显-回显", tags = "生产部-生产作业-补单派工")
    public ResponseInfo suppDispatchTempProcessBack(@RequestParam@ApiParam(required = true,value = "订单号") String slipNo,
                                                @RequestParam(required = false)@ApiParam(value = "工艺") String process) {
        return ResponseInfo.ok(service.suppDispatchTempProcessBack(slipNo,process,processCode));
    }

    @WebLogger
    @PostMapping("/suppDispatchTempSizeBack")
    @ApiOperation(value = "号码回显-回显", tags = "生产部-生产作业-补单派工")
    public ResponseInfo suppDispatchTempSizeBack(@RequestParam@ApiParam(required = true,value = "订单号") String slipNo,
                                                @RequestParam(required = false)@ApiParam(value = "号码") String sizeNo) {
        return service.suppDispatchTempSizeBack(slipNo,sizeNo,processCode);
    }

    @WebLogger
    @PutMapping("/suppDispatchAdd")
    @ApiOperation(value = "派工-新增", tags = "生产部-生产作业-补单派工")
    public ResponseInfo suppDispatchAdd(@RequestBody SuppDispatchRequest request) {
        return ResponseInfo.ok(service.suppDispatchAdd(request,processCode));
    }

    @WebLogger
    @PutMapping("/suppDispatchDelete")
    @ApiOperation(value = "删除派工单-删除", tags = "生产部-生产作业-补单派工")
    public ResponseInfo suppDispatchDelete(@RequestBody List<PcCuttingDispatchOther> request) {
        return service.suppDispatchDelete(request,processCode);
    }
}